// ignore_for_file: must_be_immutable

import 'package:aitao_flutter/style/box_style.dart';
import 'package:aitao_flutter/style/color_style.dart';
import 'package:aitao_flutter/style/edgeInsets_style.dart';
import 'package:aitao_flutter/style/radius_style.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class OnlineStatus extends StatefulWidget {
  OnlineStatus({Key? key, required this.status}) : super(key: key);
  int status;
  @override
  State<OnlineStatus> createState() => _OnlineStatusState();
}

class _OnlineStatusState extends State<OnlineStatus> {
  var circleColor = ColorStyle.setColor(0xFF7F7F7F);
  var statusStr = '空闲';
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsetsStyle.edgeInsets(4, 0),
      decoration: BoxDecoration(
          borderRadius: RadiusStyle.radiusAll(8.w),
          color: ColorStyle.setColor(0xFFCCCCCC)),
      width: 38.w,
      height: 15.w,
      child: Row(
        children: [
          Container(
              decoration: BoxDecoration(
                borderRadius: RadiusStyle.radiusAll(2.5.w),
                color: circleColor,
              ),
              width: 5.w,
              height: 5.w),
          Box.hBox3,
          Text(
            statusStr,
            style: const TextStyle(fontSize: 11, color: ColorStyle.whiteColor),
          )
        ],
      ),
    );
    // ic_home_offline ic_home_free ic_home_busy ic_wurao
  }

  @override
  void initState() {
    super.initState();
    if (widget.status == 1) {
      circleColor = ColorStyle.setColor(0xFFE8A06A);
      statusStr = '勿扰';
    } else if (widget.status == 2) {
      circleColor = ColorStyle.setColor(0xFFE8A06A);
      statusStr = '忙碌';
    } else if (widget.status == 3) {
      circleColor = ColorStyle.setColor(0xFF5BE03F);
      statusStr = '空闲';
    } else if (widget.status == 4) {
      circleColor = ColorStyle.setColor(0xFF7F7F7F);
      statusStr = '离线';
    }
    setState(() {});
  }
}
